package com.furnitur.core.mapper.favorite;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.furnitur.core.entity.favorite.Favorite;
import com.furnitur.modules.portal.vo.favorite.FavoriteVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface FavoriteMapper extends BaseMapper<Favorite> {
    
    @Select("SELECT f.id, f.furniture_id, fu.name as furniture_name, " +
            "fu.image_url, fu.price, fu.stock, " +
            "fu.merchant_id, u.username as merchant_name, f.created_at " +
            "FROM favorites f " +
            "LEFT JOIN furniture fu ON f.furniture_id = fu.id " +
            "LEFT JOIN users u ON fu.merchant_id = u.id " +
            "WHERE f.user_id = #{userId}")
    List<FavoriteVO> selectUserFavorites(@Param("userId") Long userId);
} 